package com.kangyi.app.mapper;

import com.github.pagehelper.Page;
import com.kangyi.app.annotation.AutoFill;
import com.kangyi.dto.CharityRegistrationsDTO;
import com.kangyi.entity.ActivitySignup;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.CharityRegistrationsVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface ActivitySignupMapper {

    @Select("select count(*) from activity_signup where activity_id = #{id};")
    Integer getTotal(Integer id);

    @Select("select * from activity_signup where guests_staying_id = #{guestsStayingId} and activity_id = #{activityId};")
    ActivitySignup getByGuestsStayingIdAndActivityId(Integer guestsStayingId, Integer activityId);

    @Insert("insert into activity_signup(user_id, guests_staying_id, activity_id, signup_time, status, create_user, update_user, create_time, update_time) " +
            "VALUES (#{userId},#{guestsStayingId},#{activityId},#{signupTime},#{status},#{createUser},#{updateUser},#{createTime},#{updateTime})")
    @AutoFill(value = OperationType.INSERT)
    void signUpActivity(ActivitySignup build);

    @Select("select * from activity_signup where id = #{registrationId};")
    ActivitySignup getById(Integer registrationId);

    @Delete("delete from activity_signup where id = #{registrationId};")
    void deleteActivitySignup(Integer registrationId);

    Page<CharityRegistrationsVO> charityRegistrations(CharityRegistrationsDTO charityRegistrationsDTO);
}
